import URL from './request.js'

/**
 * 处理图片地址
 * @param {*} url
 * @returns
 */
export const dalImg = (URL) => {
  if (URL) {
    if (URL.startsWith('http')) {
      return URL
    } else {
      return serverUrl + URL
    }
  } else {
    return 'https://img2.baidu.com/it/u=2833484760,1116678162&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  }
}

/**
 * 设置
 * @param {*} token
 */
export const setToken = (token) => {
  sessionStorage.setItem('token', token)
}

export const getToken = (token) => sessionStorage.getItem('token')

export const removeToken = (token) => sessionStorage.removeItem('token')

/**是否登录 */
export const isLogined = () => (getToken() ? true : false)
